package cn.livingCloud.controller.content.front;

import cn.livingCloud.dto.front.ArticleFrontDto;
import cn.livingCloud.dto.front.ArticleFrontListDto;
import cn.livingCloud.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 前台文章显示
 * Created by DingJie  on 2016/1/21.
 */
@Controller
@RequestMapping("/article")
public class ArticleDisplayController {
    @Autowired
    private ArticleService service;

    @RequestMapping("/display.htm")
    public String load(@RequestParam String uuid, Model model) {
        ArticleFrontDto articleDto = service.getArticleFrontDto(uuid);
        model.addAttribute("articleDto", articleDto);
        return "front/article/article";
    }

    @RequestMapping("/list.htm")
    public String list(ArticleFrontListDto listFrontDto, Model model) {
        service.getArticleFrontListDto(listFrontDto);
        model.addAttribute("listFrontDto", listFrontDto);
        return "front/article/list";
    }

    @RequestMapping("/load_more")
    public String loadMore(ArticleFrontListDto listDto, Model model) {
        list(listDto, model);
        return "front/article/article_more";
    }
}
